package com.david.trade.clear.task;

import com.david.trade.clear.service.TcpMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.ArrayList;
import java.util.List;

/**
 * @author admin
 */
//@Configuration
//@EnableScheduling
@Slf4j
public class TcpMessageTask {

    public static List<TcpMessage> tcpMessageTaskList = new ArrayList<>();


//    @Scheduled(fixedRate=10000)
    private void configureTasks() {
        log.info("执行定时任务，tcpMessageTaskList的长度：{}", tcpMessageTaskList.size());
        if (!tcpMessageTaskList.isEmpty()) {
            for(TcpMessage tcpMessage : tcpMessageTaskList) {
                tcpMessage.getTcpHandler().reply(tcpMessage.getMsgId(), "result");
            }
            tcpMessageTaskList.clear();
        }
    }

}
